<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

  
  <title>server测试工具 | Abel&#39;Blog</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="记录一下常用的服务器测试工具。 网络相关抓包工具网络分析 wireshark_v3.4.5tcpdump通过指令安装yum install tcpdump。 12345678910111213141516171819202122232425$ tcpdump  -XvvennSs 0 -i enp2s0 port 808020:01:34.640787 94:c6:91:57:e4:1b &gt;">
<meta property="og:type" content="article">
<meta property="og:title" content="server测试工具">
<meta property="og:url" content="http://example.com/2021/07/28/2021/2021-06-21-server%E6%B5%8B%E8%AF%95%E5%B7%A5%E5%85%B7/index.html">
<meta property="og:site_name" content="Abel&#39;Blog">
<meta property="og:description" content="记录一下常用的服务器测试工具。 网络相关抓包工具网络分析 wireshark_v3.4.5tcpdump通过指令安装yum install tcpdump。 12345678910111213141516171819202122232425$ tcpdump  -XvvennSs 0 -i enp2s0 port 808020:01:34.640787 94:c6:91:57:e4:1b &gt;">
<meta property="og:locale" content="en_US">
<meta property="article:published_time" content="2021-07-28T03:33:01.260Z">
<meta property="article:modified_time" content="2021-07-22T09:02:16.412Z">
<meta property="article:author" content="Abel Sean">
<meta property="article:tag" content="Server">
<meta name="twitter:card" content="summary">
  
    <link rel="alternate" href="/atom.xml" title="Abel&#39;Blog" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  
<link rel="stylesheet" href="/css/style.css">

<meta name="generator" content="Hexo 5.4.0"></head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">Abel&#39;Blog</a>
      </h1>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://example.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-2021/2021-06-21-server测试工具" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2021/07/28/2021/2021-06-21-server%E6%B5%8B%E8%AF%95%E5%B7%A5%E5%85%B7/" class="article-date">
  <time datetime="2021-07-28T03:33:01.260Z" itemprop="datePublished">2021-07-28</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      server测试工具
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>记录一下常用的服务器测试工具。</p>
<h2 id="网络相关"><a href="#网络相关" class="headerlink" title="网络相关"></a>网络相关</h2><h3 id="抓包工具"><a href="#抓包工具" class="headerlink" title="抓包工具"></a>抓包工具</h3><p><a target="_blank" rel="noopener" href="https://blog.csdn.net/bandaoyu/article/details/107118729">网络分析</a></p>
<h4 id="wireshark-v3-4-5"><a href="#wireshark-v3-4-5" class="headerlink" title="wireshark_v3.4.5"></a>wireshark_v3.4.5</h4><h4 id="tcpdump"><a href="#tcpdump" class="headerlink" title="tcpdump"></a>tcpdump</h4><p>通过指令安装<code>yum install tcpdump</code>。</p>
<figure class="highlight zsh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line">$ tcpdump  -XvvennSs 0 -i enp2s0 port 8080</span><br><span class="line"></span><br><span class="line">20:01:34.640787 94:c6:91:57:e4:1b &gt; d4:5d:64:f0:76:aa, ethertype IPv4 (0x0800), length 54: (tos 0x0, ttl 64, id 23026, offset 0, flags [DF], proto TCP (6), length 40)</span><br><span class="line">    192.168.125.213.8080 &gt; 192.168.125.196.11743: Flags [.], cksum 0x7f69 (correct), seq 2141321887, ack 3936026461, win 471, length 0</span><br><span class="line">	0x0000:  4500 0028 59f2 4000 4006 63f3 c0a8 7dd5  E..(Y.@.@.c...&#125;.</span><br><span class="line">	0x0010:  c0a8 7dc4 1f90 2ddf 7fa1 fa9f ea9a ff5d  ..&#125;...-........]</span><br><span class="line">	0x0020:  5010 01d7 7f69 0000                      P....i..</span><br><span class="line">20:01:34.648655 94:c6:91:57:e4:1b &gt; d4:5d:64:f0:76:aa, ethertype IPv4 (0x0800), length 415: (tos 0x0, ttl 64, id 23027, offset 0, flags [DF], proto TCP (6), length 401)</span><br><span class="line">    192.168.125.213.8080 &gt; 192.168.125.196.11743: Flags [P.], cksum 0xe9dc (correct), seq 2141321887:2141322248, ack 3936026461, win 471, length 361: HTTP, length: 361</span><br><span class="line">	HTTP/1.1 200 OK</span><br><span class="line">	Content-Type: application/json; charset=utf-8</span><br><span class="line">	Date: Mon, 21 Jun 2021 12:01:34 GMT</span><br><span class="line">	Content-Length: 237</span><br><span class="line">	</span><br><span class="line">	0x0000:  4500 0191 59f3 4000 4006 6289 c0a8 7dd5  E...Y.@.@.b...&#125;.</span><br><span class="line">	0x0010:  c0a8 7dc4 1f90 2ddf 7fa1 fa9f ea9a ff5d  ..&#125;...-........]</span><br><span class="line">	0x0020:  5018 01d7 e9dc 0000 4854 5450 2f31 2e31  P.......HTTP/1.1</span><br><span class="line">	0x0030:  2032 3030 204f 4b0d 0a43 6f6e 7465 6e74  .200.OK..Content</span><br><span class="line">	0x0090:  7465 6e74 2d4c 656e 6774 683a 2032 3337  tent-Length:.237</span><br><span class="line">	0x00a0:  0d0a 0d0a 7b22 5549 4422 3a34 372c 224c  ....&#123;<span class="string">&quot;UID&quot;</span>:47,<span class="string">&quot;L</span></span><br><span class="line"><span class="string">	0x00b0:  6f62 6279 4164 6472 223a 2231 3932 2e31  obbyAddr&quot;</span>:<span class="string">&quot;192.1</span></span><br><span class="line"><span class="string">	0x00c0:  3638 2e31 3235 2e31 3936 3a32 3636 3622  68.125.196:2666&quot;</span></span><br><span class="line">	0x0170:  3565 3436 3264 6331 3866 3963 3063 3661  5e462dc18f9c0c6a</span><br><span class="line">	0x0180:  3366 6439 6465 3261 3835 6538 6522 7d5d  3fd9de2a85e8e<span class="string">&quot;&#125;]</span></span><br><span class="line"><span class="string">	0x0190:  7d                                       </span></span><br></pre></td></tr></table></figure>

<p>所以，在工作中 tcpdump 只是用来抓取数据包，不用来分析数据包，而是把 tcpdump 抓取的数据包保存成 pcap 后缀的文件，接着用 Wireshark 工具进行数据包分析。</p>
<p>先使用指令将侦听到的数据写入文件，<code>tcpdump  -XvvennSs 0 -i enp2s0 port 8080 -w http_tcpdump.pcap</code>。然后使用wireshark来看。</p>
<p><a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/82498482">wireshark说明文档</a></p>
<h3 id="网络限制工具"><a href="#网络限制工具" class="headerlink" title="网络限制工具"></a>网络限制工具</h3><h4 id="TC"><a href="#TC" class="headerlink" title="TC"></a>TC</h4><p>TC是限速命令，<code>wondershaper</code>是国外人开发的一款在Linux内核下基于TC工具的对整块网卡的限度工具。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">yum install epel-release -y</span><br><span class="line">yum install wondershaper -y</span><br></pre></td></tr></table></figure>

<p><a target="_blank" rel="noopener" href="https://www.cnblogs.com/cainiaoit/p/8582322.html">TC工具</a></p>
<h3 id="监控网络使用率"><a href="#监控网络使用率" class="headerlink" title="监控网络使用率"></a>监控网络使用率</h3><p>使用iftop工具能监控服务器通讯情况<code>yum install iftop</code>。</p>
<h3 id="网上找到的建议"><a href="#网上找到的建议" class="headerlink" title="网上找到的建议"></a>网上找到的建议</h3><p>ip：查看网卡上的总流量<br>来自 iproute2util 包，在大多数系统上都已经默认安装，也可通过 yum install -y iproute 安装<br>nload：查看各个网络设备的当前网络速率<br>来自EPEL软件库，安装：yum install -y epel-release &amp;&amp; yum install -y nload<br>iptraf-ng：可以输出网卡的tcp、udp等各种数据，和各个网卡的实时网速<br>默认未安装，可使用 yum install -y iptraf-ng 安装<br>stat：用来替换vmstat、iostat、netstat、nfsstat和ifstat的全能系统信息统计工具，支持数据实时刷新，输出直观易懂<br>默认没有安装，安装命令为：yum install -y dstat<br>sar：System Activity Report的缩写，是一款全面的Linux系统运行状态统计和性能分析工具，可从磁盘IO、CPU负载、内存使用等多个维度对系统活动进行报告<br>来自 sysstat 包，安装：yum install -y sysstat<br>ss 和 netstat：查看活动链接/监听端口的常用命令。ss 是 netstat 的替代，性能更好，建议使用<br>ss 是 iproute2util 包的一部分，netstat 来自 net-tools 包，新版系统上需要自行安装：yum install -y net-tools<br>nethogs：查看单个进程流量而设计的工具，按照进程进行带宽分组<br>来自EPEL软件库，安装命令是：yum install -y epel-release &amp;&amp; yum install -y nethogs<br>tcpdump：用来抓包，保存的数据可以用wireshark打开和查看</p>
<p>版权声明：本文为CSDN博主「guotianqing」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。<br><a target="_blank" rel="noopener" href="https://blog.csdn.net/guotianqing/article/details/109822561">原文链接</a></p>
<p><a target="_blank" rel="noopener" href="https://www.zhihu.com/question/19862245">Linux网络工具</a></p>
<p>nethogs: 按进程查看流量占用<br>iptraf: 按连接/端口查看流量<br>ifstat: 按设备查看流量<br>ethtool: 诊断工具<br>tcpdump: 抓包工具<br>ss: 连接查看工具<br>其他: dstat, slurm, nload, bmon</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://example.com/2021/07/28/2021/2021-06-21-server%E6%B5%8B%E8%AF%95%E5%B7%A5%E5%85%B7/" data-id="ckrn3an7i001v20xwging3i4b" class="article-share-link">Share</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Server/" rel="tag">Server</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="/2021/07/28/2021/2021-06-22-go-ethereum-learn/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          go-ethereum阅读笔记
        
      </div>
    </a>
  
  
    <a href="/2021/07/28/2021/2021-06-09-pprof-doc/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">go-pprof</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/tags/3D/" rel="tag">3D</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/AI/" rel="tag">AI</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/C/" rel="tag">C++</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Game/" rel="tag">Game</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Go/" rel="tag">Go</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Linux/" rel="tag">Linux</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Math/" rel="tag">Math</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Server/" rel="tag">Server</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Unreal-Engine4/" rel="tag">Unreal Engine4</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/git/" rel="tag">git</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/golang/" rel="tag">golang</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/guitar/" rel="tag">guitar</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/node-js/" rel="tag">node.js</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/protobuf/" rel="tag">protobuf</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/python/" rel="tag">python</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/recast/" rel="tag">recast</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/redis/" rel="tag">redis</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/type/" rel="tag">type</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/vscode/" rel="tag">vscode</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/%E8%BF%90%E7%BB%B4/" rel="tag">运维</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="/tags/3D/" style="font-size: 10px;">3D</a> <a href="/tags/AI/" style="font-size: 11.67px;">AI</a> <a href="/tags/C/" style="font-size: 15px;">C++</a> <a href="/tags/Game/" style="font-size: 18.33px;">Game</a> <a href="/tags/Go/" style="font-size: 13.33px;">Go</a> <a href="/tags/Linux/" style="font-size: 13.33px;">Linux</a> <a href="/tags/Math/" style="font-size: 11.67px;">Math</a> <a href="/tags/Server/" style="font-size: 16.67px;">Server</a> <a href="/tags/Unreal-Engine4/" style="font-size: 10px;">Unreal Engine4</a> <a href="/tags/git/" style="font-size: 10px;">git</a> <a href="/tags/golang/" style="font-size: 20px;">golang</a> <a href="/tags/guitar/" style="font-size: 10px;">guitar</a> <a href="/tags/node-js/" style="font-size: 10px;">node.js</a> <a href="/tags/protobuf/" style="font-size: 10px;">protobuf</a> <a href="/tags/python/" style="font-size: 10px;">python</a> <a href="/tags/recast/" style="font-size: 11.67px;">recast</a> <a href="/tags/redis/" style="font-size: 10px;">redis</a> <a href="/tags/type/" style="font-size: 10px;">type</a> <a href="/tags/vscode/" style="font-size: 10px;">vscode</a> <a href="/tags/%E8%BF%90%E7%BB%B4/" style="font-size: 16.67px;">运维</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/07/">July 2021</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2021/07/28/2021/2021-07-19-etcd-learn/">go-etcd阅读笔记</a>
          </li>
        
          <li>
            <a href="/2021/07/28/2021/2021-06-22-go-ethereum-learn/">go-ethereum阅读笔记</a>
          </li>
        
          <li>
            <a href="/2021/07/28/2021/2021-06-21-server%E6%B5%8B%E8%AF%95%E5%B7%A5%E5%85%B7/">server测试工具</a>
          </li>
        
          <li>
            <a href="/2021/07/28/2021/2021-06-09-pprof-doc/">go-pprof</a>
          </li>
        
          <li>
            <a href="/2021/07/28/2021/2021-04-19-c++-metaprogramming/">c++metaprogramming</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2021 Abel Sean<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  
<link rel="stylesheet" href="/fancybox/jquery.fancybox.css">

  
<script src="/fancybox/jquery.fancybox.pack.js"></script>




<script src="/js/script.js"></script>




  </div>
</body>
</html>